<link rel="stylesheet" th:href="@{/css/base.css}">
<script src="/jquery/jquery.min.js"></script>
<!-- 页面上方 -->
<div class="row header" th:fragment="baseheader">
    <div class="col-md-12">
        <div class="col-md-6" style="margin-top: 13px;"><b style="font-size: 30px;">学生成绩管理系统</b></div>
        <div class="col-md-6" style="text-align: right;margin-top: 13px;">
            <b id="name" style=" color: #fff;"></b>
            <a href="#" id="logout" style=" color: #fff;"><u>退出登录</u></a>
        </div>
        <div class="col-md-1"></div>
    </div>
</div>

<!-- 左侧菜单 -->
<div class="menu" th:fragment="basemenu">
    <div class="menutitle">
        <b style="font-size: 26px;margin-left: 30px;">导航菜单</b>
    </div>
    <div id="menucontent">
        <div class="menuoptions" id="information" onclick="showinformation()">信息管理<span style="margin-right: 20px;float:right;"><i class="fa fa-caret-left" aria-hidden="true"></i></span></div>
        <div id="informationcontent" style="display:none;background-color:#eee;border-radius: 5px;">
            <a href="/student"><div class="menuoption"><i class="fa fa-user-o" aria-hidden="true"></i>&nbsp;&nbsp;学生信息</div></a>
            <a href="/teacher"><div class="menuoption"><i class="fa fa-user-circle-o" aria-hidden="true"></i>&nbsp;&nbsp;教师信息</div></a>
        </div>
        <div class="menuoptions" id="achievement" onclick="showachievement()">成绩管理<span style="margin-right: 20px;float:right;"><i class="fa fa-caret-left" aria-hidden="true"></i></span></div>
        <div id="achievementcontent" style="display:none;background-color:#eee;border-radius: 5px;">
            <a href="/examresult"><div class="menuoption"><i class="fa fa-search" aria-hidden="true"></i>&nbsp;&nbsp;成绩查询</div></a>
            <a href="/mangeinto"><div class="menuoption"><i class="fa fa-pencil-square-o" aria-hidden="true"></i>&nbsp;&nbsp;成绩录入</div></a>
            <a href="/get_result"><div class="menuoption"><i class="fa fa-bar-chart" aria-hidden="true"></i>&nbsp;&nbsp;成绩分析</div></a>
        </div>
        <div class="menuoptions" id="course" onclick="showcourse()">课程管理<span style="margin-right: 20px;float:right;"><i class="fa fa-caret-left" aria-hidden="true"></i></span></div>
        <div id="coursecontent" style="display:none;background-color:#eee;border-radius: 5px;">
            <a href="/courseinfo"><div class="menuoption"><i class="fa fa-table" aria-hidden="true"></i>&nbsp;&nbsp;课程信息</div></a>
            
        </div>
    </div>
    <script>
        var name = '[[${session.name}]]';
        console.log("name:", name)
        var perm = '[[${session.perm}]]';
        console.log("perm", perm)
        var admin = '[[${session.admin}]]';
        console.log("admin", admin)
        if(perm==1 && admin==0){
            $("#name").append("欢迎 ", name, " 老师登录！");
        }else if(perm==1 && admin==1){
            $("#name").append("欢迎 ", name, " 管理员登录！");
        }else{
            $("#name").append("欢迎 ", name, " 同学登录！");
        }
         
        function showinformation(){
            var infocon = document.getElementById('informationcontent');
            var info = document.getElementById('information')
            if(infocon.style.display == 'none'){
                infocon.style.display = 'block';
                info.children[0].innerHTML = '<i class="fa fa-caret-down" aria-hidden="true"></i>';
            }else{
                infocon.style.display = 'none';
                info.children[0].innerHTML = '<i class="fa fa-caret-left" aria-hidden="true"></i>';
            }
        }
        function showachievement(){
            var achcon = document.getElementById('achievementcontent');
            var ach = document.getElementById('achievement');
            if(achcon.style.display == 'none'){
                achcon.style.display = 'block';
                ach.children[0].innerHTML = '<i class="fa fa-caret-down" aria-hidden="true"></i>';
            }else{
                achcon.style.display = 'none';
                ach.children[0].innerHTML = '<i class="fa fa-caret-left" aria-hidden="true"></i>';
            }
        }
        function showcourse(){
            var coursecon = document.getElementById('coursecontent');
            var course = document.getElementById('course');
            if(coursecon.style.display == 'none'){
                coursecon.style.display = 'block';
                course.children[0].innerHTML = '<i class="fa fa-caret-down" aria-hidden="true"></i>';
            }else{
                coursecon.style.display = 'none';
                course.children[0].innerHTML = '<i class="fa fa-caret-left" aria-hidden="true"></i>';
            }
        }
        $(document).on("click", "#logout", (function(){
            if(confirm("是否退出登录？")){
                window.location.href="/logout";
            }
        }));
        
        
    </script>
</div>
<div class="row container" th:fragment="basecontainer">
</div>

<!-- 页面底部 -->
<div class=" footer" th:fragment="basefooter"></div>
